# 判断 文件 存不存在？
import os.path
import xlrd2


def file_exist(filename):
    """
    判断文件是否存在
    :param filename: 文件名
    :return:
    """
    if os.path.isfile(filename):
        return True
    raise Exception('文件没了！！')


def read_text(filename, seq=','):
    """
    读取文件中的数据
    :param filename: 文件名
    :param seq: 分隔符号
    :return:
    """
    file_exist(filename)
    with open(filename, encoding='utf-8') as f:
        result = []
        for line in f:
            result.append(line.strip().split(seq))
        return result


def read_excel(excel_name):
    """
    读取 excel 文档中的 内容
    :param excel_name: 文件名字
    :return:
    """
    file_exist(excel_name)
    book = xlrd2.open_workbook(excel_name)

    sheet = book.sheet_by_index(0)
    result = []
    for i in range(sheet.nrows):
        result.append(sheet.row_values(i))
    return result


if __name__ == '__main__':
    # print(file_exist('../data.txt'))\
    # print(read_text('data.txt'))
    print(read_excel('dataContent.xls'))
